package com.sxfq.loansupermarket.backsystem.modular.logs.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.core.util.StringUtil;
import com.sxfq.loansupermarket.backsystem.modular.logs.dao.ReservationsLogDao;
import com.sxfq.loansupermarket.backsystem.modular.logs.entity.ReservationsDeleteLogInfo;
import com.sxfq.loansupermarket.backsystem.modular.logs.entity.ReservationsUpdateLogInfo;
import com.sxfq.loansupermarket.backsystem.modular.logs.entity.SearchReservationsDeleteLogInfo;
import com.sxfq.loansupermarket.backsystem.modular.logs.entity.SearchReservationsUpdateLogInfo;
import com.sxfq.loansupermarket.backsystem.modular.logs.service.IReservationsLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ReservationsLogServiceImpl implements IReservationsLogService {

    @Autowired
    private ReservationsLogDao dao;

    @Override
    public List<ReservationsDeleteLogInfo> getDeleteList(Page<ReservationsDeleteLogInfo> page, SearchReservationsDeleteLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getArchiving())) {
            params.put("archiving", searchInfo.getArchiving());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        return dao.getDeleteList(page, params);
    }

    @Override
    public List<ReservationsUpdateLogInfo> getUpdateList(Page<ReservationsUpdateLogInfo> page, SearchReservationsUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getArchiving())) {
            params.put("archiving", searchInfo.getArchiving());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        return dao.getUpdateList(page, params);
    }

}

